using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Xml;
using Thinxoft.HttpLib;
using System.Text;
using System.Collections.Generic;
using System.IO;

namespace Thinxoft.XedusLive
{
    partial class WebAdmin
    {
        void LoadDirectoryFiles(HttpApplication xapp)
        {
            dirfiles = new Dictionary<string, string>();
            listViewFiles.Items.Clear();
            string[] dirs = System.IO.Directory.GetDirectories(xapp.DocumentRoot);

            foreach (string dir in dirs)
            {
                string shortname = System.IO.Path.GetFileName(dir);
                listViewFiles.Items.Add(new ListViewItem(shortname, 1));
                dirfiles.Add(shortname, dir);
            }


            string[] fs = System.IO.Directory.GetFiles(xapp.DocumentRoot);


            foreach (string file in fs)
            {
                string name = System.IO.Path.GetFileName(file);
                listViewFiles.Items.Add(new ListViewItem(name, 2));
                dirfiles.Add(name, file);
            }
        }

        void LoadDirectoryFiles(string target)
        {
            dirfiles = new Dictionary<string, string>();
            listViewFiles.Items.Clear();
            string[] dirs = System.IO.Directory.GetDirectories(target);

            if (currentpath != settings.HttpApplications[this.app].DocumentRoot)
            {
                dirfiles.Add("..", Directory.GetParent(target).FullName);
                listViewFiles.Items.Add(new ListViewItem("..", 0));
            }


            foreach (string dir in dirs)
            {
                string shortname = System.IO.Path.GetFileName(dir);
                listViewFiles.Items.Add(new ListViewItem(shortname, 1));
                dirfiles.Add(shortname, dir);
            }


            string[] fs = System.IO.Directory.GetFiles(target);


            foreach (string file in fs)
            {
                string name = System.IO.Path.GetFileName(file);
                listViewFiles.Items.Add(new ListViewItem(name, 2));
                dirfiles.Add(name, file);
            }
        }
    }
}
